package cate.game.pvp.championrace.data;

import cate.game.util.GameKit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.Id;

@Data
public class ChampionRaceRankRwd {

    @Id
    private String id = GameKit.uid();

    private String uid;
    private int season;
    private int srvId;
    private int rank;

    public static ChampionRaceRankRwd of(String uid, int season, int srvId, int rank) {
        ChampionRaceRankRwd rankRwd = new ChampionRaceRankRwd();
        rankRwd.setUid(uid);
        rankRwd.setSeason(season);
        rankRwd.setSrvId(srvId);
        rankRwd.setRank(rank);
        return rankRwd;
    }

    @JsonIgnore
    public String getSrvIdIndexName() {
        return getSrvIdIndexName(season, srvId);
    }

    @JsonIgnore
    public String getIndexedKey() {
        return String.format("%s-%d-%d", uid, season, srvId);
    }

    public static String getSrvIdIndexName(int season, int srvId) {
        return String.format("%d-%d", season, srvId);
    }
}
